<?php

namespace Yolo\Errors;

class ResponseError extends RpcApiError
{
    public function __construct(string $type, string $symbol, string $message, int $code = null)
    {
        $this->type = $type;
        $this->symbol = $symbol;
        $this->message = $message;

        $registry = ExceptionRegistry::inst();
        $types = $registry->getModuleTypes();
        $this->module = $types[$type]['module'];
        if (is_null($code)) {
            $codeIndex = $types[$type]['index'];
            $this->code = $codeIndex();
        } else {
            $this->code = $code;
        }
    }
}